# -*- coding: utf-8 -*-
#   combo部件
# @Time    ： 2023/2/16  16:51
# @Auther  ： 徐良
# File     :  comboParts.py

from PySide6.QtWidgets import QComboBox
from PySide6.QtGui import QStandardItemModel, QStandardItem
from PySide6.QtCore import Qt
from share.domainFunction import combox_TypeList, combox_WidgetHeadList, combox_AlignList, \
    combox_WidgetBodyList, combox_WidgetList


class baseComboOne(QComboBox):
    """
    基础类1
    """
    def __init__(self, parent=None):
        super(baseComboOne, self).__init__(parent)


class ComBox_Type(baseComboOne):
    """
    数据类型
    """
    def __init__(self, parent=None):
        super(ComBox_Type, self).__init__(parent)
        self.nameList = combox_TypeList.copy()
        self.addItems(self.nameList)
        self.Text = self.nameList[0]
        self.currentIndexChanged.connect(self.onChange)


    def onChange(self, index):
        if 0 <= index < len(self.nameList):
            self.Text = self.nameList[index]


class ComBox_Align(baseComboOne):
    """
    对齐
    """
    def __init__(self, parent=None):
        super(ComBox_Align, self).__init__(parent)
        self.nameList = combox_AlignList.copy()
        self.addItems(self.nameList)
        self.Text = self.nameList[0]
        self.currentIndexChanged.connect(self.onChange)


    def onChange(self, index):
        if 0 <= index < len(self.nameList):
            self.Text = self.nameList[index]


class ComBox_WidgetHead(baseComboOne):
    """
    用于表头的控件
    """
    def __init__(self, parent=None):
        super(ComBox_WidgetHead, self).__init__(parent)
        self.nameList = combox_WidgetHeadList.copy()
        self.addItems(self.nameList)
        self.Text = self.nameList[0]
        self.currentIndexChanged.connect(self.onChange)


    def onChange(self, index):
        if 0 <= index < len(self.nameList):
            self.Text = self.nameList[index]


class ComBox_WidgetBody(baseComboOne):
    """
    用于表头的控件
    """
    def __init__(self, parent=None):
        super(ComBox_WidgetBody, self).__init__(parent)
        self.nameList = combox_WidgetBodyList.copy()
        self.addItems(self.nameList)
        self.Text = self.nameList[0]
        self.currentIndexChanged.connect(self.onChange)


    def onChange(self, index):
        if 0 <= index < len(self.nameList):
            self.Text = self.nameList[index]


class ComBox_Widget(baseComboOne):
    """
    用于系统配制，如ebWork 主从表等
    """

    def __init__(self, parent=None):
        super(ComBox_Widget, self).__init__(parent)
        self.nameList = combox_WidgetList.copy()
        self.addItems(self.nameList)
        self.Text = self.nameList[0]
        self.currentIndexChanged.connect(self.onChange)

    def onChange(self, index):
        if 0 <= index < len(self.nameList):
            self.Text = self.nameList[index]


